package com.freemalll.merchant.domain.dto.coopManagement;

import com.freemalll.merchant.utils.ColumnName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author songshixiong
 * @ClassName AssetManagementEditDto
 * @description:
 * @date 2025年04月29日
 * @version: 1.0
 */
@Data
public class AssetManageDetailEditDto {

    @Schema(description = "明细id")
    private String sourceDetailId;

    @Schema(description = "资方主键")
    private String sourceId;

    @Schema(description = "启用状态： 0 否 1 是")
    private Integer enableFlag;

    @Schema(description = "支持场景： 大健康： GREAT_HEALTH 教育：EDUCATION")
    private String supportingScenarios;

    @Schema(description = "合作状态：正常合作：NORMAL_COOPERATION 暂停合作： SUSPEND_COOPERATION  停止合作： TERMINATION_COOPERATION")
    @ColumnName("“合作状态”")
    private String cooperationStatus;

    @Schema(description = "推单状态： 正常推单：NORMAL_PUSH_ORDERS 暂停推单： PAUSE_PUSH_ORDERS")
    @ColumnName("“推单状态”")
    private String pushOrderStatus;

    @Schema(description = "日限额 单位万")
    @ColumnName("“日限额”")
    private BigDecimal dailyLimit;

    @Schema(description = "月限额 单位万")
    @ColumnName("“月限额”")
    private BigDecimal monthlyLimit;

    @Schema(description = "支付方式 多选 逗号隔开")
    @ColumnName("“支付方式”")
    private String payType;

    @Schema(description = "息费支持 多选 逗号隔开")
    @ColumnName("“息费支持”")
    private String interestFeeSupport;

    @Schema(description = "费率区间：最高费率")
    private BigDecimal highestRate;

    @Schema(description = "费率区间：最低费率")
    private BigDecimal minimumRate;

    @Schema(description = "费率区间")
    @ColumnName("“费率区间”")
    private String rateRange;

    @Schema(description = "年龄范围：最高年龄")
    private Integer highestAge;

    @Schema(description = "年龄范围：最低年龄")
    private Integer minimumAge;

    @Schema(description = "年龄范围")
    @ColumnName("“年龄范围”")
    private String ageRange;

    @Schema(description = "性别限制 0 无1 男 2 女")
    @ColumnName("“性别限制”")
    private Integer genderRestrictions;

    @Schema(description = "民族限制 多选 逗号隔开")
    @ColumnName("“民族限制”")
    private String ethnicRestrictions;

    @Schema(description = "职业限制 多选 逗号隔开")
    @ColumnName("“职业限制”")
    private String occupationalRestrictions;

    @Schema(description = "客户区域限制 多选 逗号隔开")
    @ColumnName("“客户区域限制”")
    private String customerRegionalRestrictions;

    @Schema(description = "项目限制 多选 逗号隔开")
    @ColumnName("“项目限制”")
    private String projectConstraints;

    @Schema(description = "授信额度：最高金额")
    private BigDecimal maximumAmount;

    @Schema(description = "授信额度：最低金额")
    private BigDecimal minimumAmount;

    @Schema(description = "授信区间")
    @ColumnName("“授信区间”")
    private String creditRange;

    @Schema(description = "期数支持 多选 逗号隔开")
    @ColumnName("“期数支持”")
    private String supportPeriods;

    @Schema(description = "授信时效：天")
    @ColumnName("“授信时效”")
    private Integer creditTimeframe;

    @Schema(description = "放款时效：天")
    @ColumnName("“放款时效”")
    private Integer lendingTimeframe;

    @Schema(description = "封禁期：天")
    @ColumnName("“封禁期”")
    private Integer banPeriod;

    @Schema(description = "二单限制： 0 无 1 有")
    @ColumnName("“二单限制”")
    private Integer twoOrderRestriction;

    @Schema(description = "商户报审 0 否1 是")
    @ColumnName("“商户报审”")
    private Integer merchantApproval;

    @Schema(description = "成立时长：天")
    @ColumnName("“成立时长”")
    private Integer establishmentDuration;

    @Schema(description = "商户区域限制 多选 逗号隔开")
    @ColumnName("“商户区域限制”")
    private String merRegionalRestrictions;

    @Schema(description = "合同签署 0 否 1 是")
    @ColumnName("“合同签署”")
    private Integer contractSigning;

    @Schema(description = "活动报备： 0 否 1 是")
    @ColumnName("“活动报备”")
    private Integer activityReporting;

    @Schema(description = "商户巡检： 0否1 是")
    @ColumnName("“商户巡检”")
    private Integer merchantInspection;

    @Schema(description = "是否代偿： 0否1是")
    @ColumnName("“是否代偿”")
    private Integer compensationFlag;

    @Schema(description = " 代偿标准")
    @ColumnName("“代偿标准”")
    private String compensationStandard;

    @Schema(description = "是否回购： 0否1是")
    @ColumnName("“是否回购”")
    private Integer buyBackFlag;

    @Schema(description = "回购标准")
    @ColumnName("“回购标准”")
    private String buyBackStandard;

    @Schema(description = "线下还款： 0否1是")
    @ColumnName("“线下还款”")
    private Integer offlineRepayment;

    @Schema(description = "线下还款比率")
    @ColumnName("“线下还款比率”")
    private BigDecimal offlineRepaymentRate;

    public void init() {
        if (this.highestRate != null && this.minimumRate != null) {
            BigDecimal highest  = this.highestRate.stripTrailingZeros();
            BigDecimal minimum = this.minimumRate.stripTrailingZeros();
            this.rateRange = minimum.toPlainString() + "-" + highest.toPlainString();
        }
        if (this.highestAge != null && this.minimumAge != null) {
            this.ageRange = this.minimumAge + "-" + this.highestAge;
        }
        if (this.minimumAmount != null && this.maximumAmount != null) {
            BigDecimal minimum  = this.minimumAmount.stripTrailingZeros();
            BigDecimal highest = this.maximumAmount.stripTrailingZeros();
            this.creditRange = minimum.toPlainString() + "-" + highest.toPlainString();
        }
    }
}
